from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter
from .views import home_view,user_view,sku_view,\
    spu_view, spu_specs_view, \
    spu_specs_options_view, sku_image_view, orders_view,\
    permission_view,permission_group_view, permission_admin_view, goods_channels_view
urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^statistical/total_count/$', home_view.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$', home_view.UserDayIncrementView.as_view()),
    url(r'^statistical/day_active/$', home_view.UserDayActiveView.as_view()),
    url(r'^statistical/day_orders/$', home_view.UserDayOrdersView.as_view()),
    url(r'^statistical/month_increment/$', home_view.UserMonthIncrementView.as_view()),
    url(r'^users/$', user_view.UserTableView.as_view()),
    # url(r'^skus/$', views.SKUTableView.as_view()),
    url(r'^goods/simple/$', sku_view.GoodSimpleView.as_view()),
    url(r'^skus/categories/$', sku_view.SKUCategoryView.as_view()),
    url(r'^goods/(?P<pk>\d+)/specs/$',sku_view.SPUSpecsView.as_view()),
    url(r'^goods/brands/simple/$', spu_view.SPUView.as_view({"get":"brand"})),
    url(r'^goods/channel/categories/$', spu_view.SPUView.as_view({"get":"category"})),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spu_view.SPUView.as_view({"get": "category_sub"})),
    url(r'^goods/images/$', spu_view.SPUView.as_view({"post":"upload_image"})),
    # url(r'^goods/specs/$', spu_specs_view.SPUSpecView.as_view({"get":"list"})),
    url(r'^goods/specs/simple/$',spu_specs_options_view.SPUSpecView.as_view()),
    url(r'^skus/simple/$', sku_image_view.SKUImageView.as_view({"get":"sku_simple"})),
    url(r'^permission/content_types/$', permission_view.PermissionContentView.as_view()),
    url(r'^permission/simple/$', permission_group_view.PermissionSimpleView.as_view()),
    url(r'^permission/groups/simple/$', permission_admin_view.PermissionGroupSimpleView.as_view()),




    # url(r'^statistical/goods_day_views/$', views.UserGoodsView.as_view()),

]
router = DefaultRouter()
router.register(r'goods/channels', goods_channels_view.GoodsChannelsView, base_name="channels")
urlpatterns += router.urls



router = DefaultRouter()
router.register(r'permission/admins', permission_admin_view.PermissionAdminView, base_name="admin")
urlpatterns += router.urls




router = DefaultRouter()
router.register(r'permission/groups', permission_group_view.PermissionGroupView, base_name="permission_group")
urlpatterns += router.urls


router = DefaultRouter()
router.register(r'permission/perms', permission_view.PermissionView, base_name="permission")
urlpatterns += router.urls



router = DefaultRouter()
router.register(r'orders', orders_view.OrdersView, base_name="orders")
urlpatterns += router.urls


router = DefaultRouter()
router.register(r'skus/images', sku_image_view.SKUImageView,base_name="sku_image")
urlpatterns += router.urls


router = DefaultRouter()
router.register(r'specs/options', spu_specs_options_view.SPUSpecsOptionsSpecView,base_name="specs")
urlpatterns += router.urls


router = DefaultRouter()
router.register(r'goods/specs', spu_specs_view.SPUSpecView, base_name="specs")
urlpatterns += router.urls


router = DefaultRouter()
router.register(r'goods', spu_view.SPUView, base_name='Spus')
urlpatterns += router.urls


router = DefaultRouter()
router.register(r'skus', sku_view.SKUTableView, base_name='Skus')
urlpatterns += router.urls
# #1,创建路由
# router = DefaultRouter()
# #2,注册视图集
# router.register(r'skus', views.SKUTableView, base_name="skus")
# #3,添加路由到urlpatterns
# urlpatterns += router.urls


# print(router.urls)